package app.blog.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import jregex.Matcher;
import app.blog.Vars;
import app.blog.service.Articles;
import app.blog.service.ModelsInjectors;
import slap.annotation.Accept;
import slap.annotation.Scan;
import slap.http.Request;
import slap.mvc.HttpRequestController;
import slap.mvc.scope.RenderModels;

@Scan
public class PostController extends HttpRequestController {
	
	private static final Logger logger = LoggerFactory.getLogger(PostController.class);
	
	@Accept(regex = "/article/(.+)")
	public void article(Matcher matcher){
		int aid = Integer.valueOf(matcher.group(1));
		RenderModels models = RenderModels.current();
		ModelsInjectors.Frontend.inject(models);
		
		models.put(Vars.Names.ARTICLE, Articles.getById(aid));
		this.renderTemplate("/single.vm");
	}
	
	@Accept(regex = "/(\\w)+")
	public void page(){
		
	}
}
